package com.ybc.chinese.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by ytzyg on 15/1/8.
 */
public class CacheDatabaseHelper extends SQLiteOpenHelper implements CacheColumns, LogColumns {

    private CacheTables table = new CacheTables();

    private static final String NAME = "ngdscache.db";
    private static final int VERSION = 2;

    public CacheDatabaseHelper(Context context) {
        super(context, NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL(table.createSQL());
        sqLiteDatabase.execSQL(table.createLogSQL());
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
        sqLiteDatabase.execSQL("drop table if exists " + TAB_NAME_LOG);
        sqLiteDatabase.execSQL(table.createLogSQL());
    }
}
